from typing import Optional, Any

import torch
from transformers import AutoTokenizer, AutoModel, AutoModelForCausalLM, BitsAndBytesConfig, TextIteratorStreamer
from langchain.llms.base import LLM
from langchain_core.prompts import ChatPromptTemplate
from langchain.schema.runnable import RunnablePassthrough
import langchain_core.messages
from threading import Thread
import gradio as gr
from langchain_huggingface import HuggingFaceEmbeddings
from langchain_community.vectorstores import FAISS
from langchain_community.document_loaders import DirectoryLoader
from langchain_core.runnables import RunnablePassthrough, RunnableParallel
import warnings

torch.cuda.empty_cache()
# "transformers==4.51.0",
# "accelerate==0.26.0",
path = r'M:\moudels\Qwen314B\Qwen3-14B'
embeddings_path = r'M:\moudels\BAAIbge-large-zh-v1.5'

with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    embeddings = HuggingFaceEmbeddings(model_name=embeddings_path)
    load = DirectoryLoader(r'F:\A_wokecode\gradio_study\langchain_study\data')
    vs = FAISS.from_documents(load.load(), embeddings)
    res = vs.similarity_search("你知道高世缘吗？介绍一下他")
    print(res)
